<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsp/common/taglib.jsp"%>
<script type="text/javascript">
	var list;
	$(function() {
		list = lyGrid({
			pagId : 'paging',
			l_column : [
					{
						colkey : "id",
						name : "id"
					},
					{
						colkey : "name",
						name : "名称"
					},
					{
						colkey : "resourceName",
						name : "resourceName",
						renderData : function(rowindex, data, rowdata, colkeyn) {
							var s = "<a target=\"_blank\" href=\"${ctx}/activiti/showresource.shtml?pdid="
									+ rowdata.id
									+ "&resource="
									+ rowdata.resourceName
									+ "\">"
									+ rowdata.resourceName + "</a>";
							return s;
						}
					},
					{
						colkey : "diagramresourcename",
						name : "diagramresourcename",
						renderData : function(rowindex, data, rowdata, colkeyn) {
							var s = "<a target=\"_blank\" href=\"${ctx}/activiti/showresource.shtml?pdid="
									+ rowdata.id
									+ "&resource="
									+ rowdata.diagramresourcename
									+ "\">"
									+ rowdata.diagramresourcename + "</a>";
							return s;
						}
					},
					{
						colkey : "key",
						name : "key"
					},
					{
						name : "操作",
						renderData : function(rowindex, data, rowdata, colkeyn) {
							var s = '<input type="button" value="删除" onclick="del('
									+ rowdata.deploymentId + ');"/>';
							return s;
						}
					} ],
			jsonUrl : '${ctx}/activiti/getprocesslists.shtml',
			checkbox : true,
			serNumber : true
		});

		$("#sub").click(
				"click",
				function() {
					var file = $("#fileupload").val();
					if (file == "") {
						alert("请选择工作流文件上传");
						return false;
					}
					var fileType = file.substring(file.lastIndexOf("."),
							file.length).toLowerCase();
					if (fileType != ".zip") {
						alert("请选择ZIP工作流文件上传");
						return false;
					}
					$("#upload").ajaxSubmit(options);
				})
		var options = {
			type : "post",
			dataType : "json",
			success : function(result) {
				if (result) {
					loadList();
				} else {
					alert("上传失败！");
				}
			}
		}
	})
	function del(id) {
		if (window.confirm("删除后不能恢复，确定删除么？")) {
			$.ajax({
				url : "${ctx}/activiti/deletedeploy.shtml",
				data : {
					deployid : id
				},
				type : "post",
				dataType : "json",
				success : function(result) {
					if (result) {
						loadList();
					}
				}
			})
		}
	}
	function loadList() {
		list.loadData();
		parent.autoHeight();
	}
</script>
<div class="container-fluid">
	<div class="row">
		<div class="col-lg-12">
			<div class="box ui-draggable ui-droppable">
				<div class="box-header">
					<div class="box-name">
						<i class="fa fa-coffee"></i> <span>上传工作流文件</span>
					</div>
					<div class="no-move"></div>
				</div>
				<div class="box-content">
					<form id="upload" action="uploadworkflow.shtml" method="post"
						enctype="multipart/form-data">
						<div class="form-group">
							<label for="fileupload">workflowupload</label> <input type="file"
								name="uploadfile" class="form-control" id="fileupload">
						</div>
						<button id="sub" type="button" class="btn btn-primary">upload</button>
					</form>
				</div>
			</div>
		</div>
	</div>

</div>
<div class="table-responsive">
	<span>已部署的工作流</span>
	<div id="paging" class="pagclass"></div>
</div>
